home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / DISK / FRDM114E / SOURCE / FDMPROTO.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-12  |  4.8 KB  |  111 lines

  1. #ifndef _FDMPROTO_H_
  2. #define _FDMPROTO_H_
  3.  
  4. /*
  5.  * There are two ways to directly support Freedom┐ and both methods
  6.  * interpret calls to the fs_iinpath memory area by fsel_[ex]input and 
  7.  * additionally pass a structure to the path.
  8.  * This procedure is simple to imagine: Reserve 128 bytes for the path 
  9.  * now it's 128+sizeof(Fdm_Str).
  10.  * In this memory (you don't have to concern yourself with global
  11.  * legibility under MiNT) the following structure will be copied,
  12.  * directly after the path string. The path will also be moved after
  13.  * the sizeof(Fdm_Str). You can now follow two different paths:
  14.  *
  15.  * 1) Simply pass a pointer to this memory area in fs_iinpath.
  16.  * Through the Magic at the start Freedom┐ immediately recognises the 
  17.  * caller supports the protocol. This method has the disadvantage that
  18.  * in the unlikely case that Freedom┐ isn't installed you can't use
  19.  * it! You must also check in the Cookie jar to see if a FSEL-Cookie 
  20.  * >= v2.0 is available (refer to SLECTRIC.H)
  21.  *
  22.  * 2) Pass a pointer to the path behind the structure. This is
  23.  * understood by other file selectors so you don't need to check the
  24.  * Cookie to see if Freedom┐ is installed. Freedom┐ can now simply 
  25.  * check sizeof(Fdm_Str), from the pointer passed, to see if the Magic 
  26.  * is present by chance, so long as MiNT with active memory protection
  27.  * isn't active. Using this method Freedom┐ can still reply that it's 
  28.  * harmless to access memory before the path:
  29.  * If Freedom┐ finds the four characters '?Fdm' after the null byte of
  30.  * the path (the same Magic as the structure expected), then it looks 
  31.  * at the following path to find the structure. And now (finally),
  32.  * the structure:
  33.  */
  34. typedef struct
  35. {
  36.     long magic;   /* '?Fdm' */
  37.     int id;       /* any Id */
  38.     int maxsel;   /* maximum number of selected files */
  39.     struct
  40.     {
  41.         unsigned fullpaths : 1; /* full pathnames in the reply */
  42.         unsigned doquote   : 1; /* Freedom┐ may quote */
  43.         unsigned noname    : 1; /* no application names before title */
  44.         unsigned sysmodal  : 1; /* System modal open */
  45.         unsigned resvd     : 28; /* reserved (set to 0) */
  46.  
  47.     } flags;
  48.     int handle;  /* After success contains the file selector's window 
  49.                     handle (or 0 if a flying dialog).
  50.                     Use: the calling program can then control the file 
  51.                         selector, perhaps it sends Freedom┐ a WM_CLOSED 
  52.                         message, or adds it to its stack of windows for 
  53.                         window-cycling.
  54.                   */
  55.     int server;  /* After success contains the application ID of the file 
  56.                         selector server. From it messages could also be 
  57.                         sent at the same time to the window's handle.
  58.                   */
  59.     char path[0]; /* The old file selector path starts here... */
  60.  
  61. } Fdm_Str;
  62.  
  63. If fsel_input returns 'magic' then '!Fdm' is returned otherwise the call 
  64. is forwarded to the OS, and the returned values (fs_iinpath, fs_iinsel, 
  65. fs_iexbutton) are valid!
  66.  
  67. If the call is successful an AES message is passed to the application. 
  68. Whether the application continues to run or waits in a sub-event loop for 
  69. the reply (in which case you process only WM_REDRAW and Co) is entirely up 
  70. to you although naturally it's better to continue running whenever 
  71. possible.
  72.  
  73. The format of the AES reply message is:
  74.  
  75. #define FILE_SELECTED    0x4560
  76. /* FILE_SELECTED: A file selector was closed:
  77.  * Word 3:   ID of the file selectors (as given by fsel_[ex]input)
  78.  * Word 4/5: Pointer to the path and extension at the time of closing
  79.  * Word 6/7: Pointer to the selected files, or NULL, if the user has 
  80.  *           cancelled the operation
  81.  *           The files are separated using spaces and use single quotes to 
  82.  *           preserve spaces inside filenames, for example:
  83.  *           'Chrisker''s paperweight'
  84.  */
  85. #ifndef FILE_SELECTED
  86. #define FILE_SELECTED        0x4560
  87. #endif
  88. /*
  89.  * On receipt of this message the program can, for the following ten
  90.  * seconds, safely access the (MiNT-global) memory, at the words 3/4
  91.  * ie 6/7, and copy the data. Afterwards Freedom┐ releases the memory
  92.  * again to GEMDOS (Mfree)!
  93.  *
  94.  *
  95.  * Should a message be sent to the Server the following messages 
  96.  * should be used instead of the standard screen manager messages
  97.  * WM_TOPPED and WM_CLOSED. Normal messages passed may well be
  98.  * unexpected. For instance the file selector may be ICFS Iconified if 
  99.  * a [Shift] key is held down (WM_CLOSED), or the object under the 
  100.  * mouse is served instead because Freedom┐ simulates background 
  101.  * operation (WM_TOPPED) under SingleTOS.
  102.  */ 
  103. #ifndef WIN_TOPPED
  104. #define WIN_TOPPED                0x7a22
  105. #endif
  106. #ifndef WIN_CLOSED
  107. #define WIN_CLOSED                0x7a23
  108. #endif
  109.  
  110. #endif /* _FDMPROTO_H_ */
  111.